home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / TIMER.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  1011 b   |  24 lines

  1. /*  timer.c - use BIOS time-of-day interrupt */
  2. #include   "stdio.h"
  3. #include   "cminor.h"
  4. #include   "asmtools.h"
  5.  
  6. long stime ;                            /* store time-of-day from last call */
  7. #define TOD_INT  0x1a                   /* BIOS time-of-day interrupt */
  8.  
  9. int  timer()                            /* count ticks since last call */
  10.   {
  11.      REGS  sreg , dreg ;
  12.      long  etime , delta ;
  13.  
  14.      sreg.ax = 0 ;                      /* get time count */
  15.      swint(TOD_INT,&sreg,&dreg) ;       /* get current count - assemble  */
  16.                                         /* 32-bit time-of-day value      */
  17.      etime = (   ((long) dreg.cx) << 16 ) + dreg.dx ;
  18.      delta = etime - stime ;
  19.      if(   (dreg.ax & 0xff) != 0 )      /* new day since last call ? */
  20.         delta = delta + 0x01800B0L ;    /* yes - add 1 day in ticks */
  21.      stime = etime ;                    /* save time-of-day for next call */
  22.      return(  (int) delta ) ;           /* return as an integer */
  23.   }
  24.